import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: MENG
 * Date: 2022-08-11
 * Time: 21:40
 */

class Person {
    public String id;
    public Person(String id){
        this.id = id;
    }

    @Override
    public String toString() {
        return "id" + id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(id, person.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

}
public class HashTest {
    //自定义/引用类型
    public static void main(String[] args) {
        Person person = new Person("1234");
        Person person1 = new Person("12");
        Person person2 = new Person("12");
        Person person3 = new Person("12");
        Person person4 = new Person("12");
        Person person5 = new Person("12");
        Person person6 = new Person("12");
        Person person7 = new Person("12");
        HashBuck2 hashBuck2 = new HashBuck2();
        hashBuck2.put(person,"吴建勇");
        hashBuck2.put(person1,"lijun");
        hashBuck2.put(person2,"a");
        hashBuck2.put(person3,"b");
        hashBuck2.put(person4,"c");
        hashBuck2.put(person5,"d");
        hashBuck2.put(person6,"e");
        hashBuck2.put(person7,"f");
        System.out.println(hashBuck2.get(person3));

        System.out.println(person1.hashCode());
        System.out.println(person2.hashCode());
        System.out.println(person3.hashCode());
        System.out.println(person4.hashCode());

    }

    public static void main1(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.put(1,110);
        hashBuck.put(2,111);
        hashBuck.put(3,112);
        hashBuck.put(14,11);
        hashBuck.put(5,11);
        hashBuck.put(6,11);
        hashBuck.put(7,11);
        hashBuck.put(8,11);
        hashBuck.put(9,11);
        hashBuck.put(10,11);
        System.out.println("=====");
        System.out.println(hashBuck.get(1));
    }
}
